package com.shareyi.study.springboot.controller;

import com.shareyi.joywindow.JoyWindowData;
import com.shareyi.study.springboot.common.HelloMan;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class TestController {

/*
    @RequestMapping(value = "/",produces = "text/plain;charset=UTF-8")
    public String index(){
        return "Hello Spring Boot!, DO you love me ?";
    }

*/

    @RequestMapping(value = "/hello")
    @ResponseBody
    public Map hello(@RequestParam(required = false) String msg){
       Map hashMap = new HashMap();
       hashMap.put("hello",msg);
        hashMap.put("xxx",null);
       return hashMap;
    }

    @RequestMapping(value = "/helloMan")
    @ResponseBody
    public HelloMan helloMan(@RequestParam(required = false) String msg){
        HelloMan helloMan = new HelloMan();
        helloMan.setName("hello");
        helloMan.setMsg("i am robot");
        return helloMan;
    }

    @RequestMapping(value = "/fileChooser")
    @ResponseBody
    public String fileChooser(){
        return JoyWindowData.getJoyWindow().getOpenPath(false, null,null);
    }



}